<?php
    include '../public/db_object.php';

    if(isset($_POST)){
        $data = $_POST['data'];
        $id_name = $_POST['id_name'];
        $id = $_POST['id'];

        // json转string
        $data = json_decode($data, true);

        $suer = $data['suer'];
        $sphone = $data['sphone'];
        $semail = $data['semail'];
        $login_name = $data['login_name'];

        // 更新数据
        $new_data = [
            'suer'=> "'$suer'",
            'sphone'=> "'$sphone'",
            'semail'=> "'$semail'",
            'login_name'=> "'$login_name'"
        ];

        $db = new DB_object(['db_name'=> 'db_shop']);
        $ret = $db->l_update_one('sys_user', $new_data, $id_name.'='.$id);

        if($ret){
            echo 1; // 更行成功
        }
        else{
          echo 0; //更行失败
        }
    }

?>